dna
holds such a sequence. Write a python snippet to generate dna
's reverse complement. Hint: remember dir
is your friend.
from random import randint s0 = [randint(1, 100) for x in xrange(20)] s1 = [randint(1, 100) for x in xrange(20)]Use a list comprehension to compute their set intersection. Use a dictionary to compute their set union.
Python has a set type. Use it to check your results. Hint: lists and sets are not directly comparable, so you'll need to explicitly bridge the gap --- the list
or set
constructor might be useful here.
Grad: Write a faster list comprehension (a dictionary might be helpful: you are allowed an extra line of code to initialize it and another to query its state). Compute primes up to 10000 both ways and compare the time. Now you can be (a little) clever.